import 'package:flutter/material.dart';
import 'package:magic_car/res/colors.dart';

class ChejiaBoard extends StatefulWidget {
  ChejiaBoard(this.chejianumpress,this.oval);
  final Function(String) chejianumpress;
  final String oval;
  _ChejiaInput createState() => _ChejiaInput();
}

class _ChejiaInput extends State<ChejiaBoard> {
  String chajiaval = "";
  List numns = [
    {'title': '1', 'value': '1'},
    {'title': '2', 'value': '2'},
    {'title': '3', 'value': '3'},
    {'title': '4', 'value': '4'},
    {'title': '5', 'value': '5'},
    {'title': '6', 'value': '6'},
    {'title': '7', 'value': '7'},
    {'title': '8', 'value': '8'},
    {'title': '9', 'value': '9'},
    {'title': '0', 'value': '0'},
    {'title': 'A', 'value': 'A'},
    {'title': 'B', 'value': 'B'},
    {'title': 'C', 'value': 'C'},
    {'title': 'D', 'value': 'D'},
    {'title': 'E', 'value': 'E'},
    {'title': 'F', 'value': 'F'},
    {'title': 'G', 'value': 'G'},
    {'title': 'H', 'value': 'H'},
    {'title': 'I', 'value': 'I'},
    {'title': 'J', 'value': 'J'},
    {'title': 'K', 'value': 'K'},
    {'title': 'L', 'value': 'L'},
    {'title': 'M', 'value': 'M'},
    {'title': 'N', 'value': 'N'},
    {'title': 'O', 'value': 'O'},
    {'title': 'P', 'value': 'P'},
    {'title': 'Q', 'value': 'Q'},
    {'title': 'R', 'value': 'R'},
    {'title': 'S', 'value': 'S'},
    {'title': 'T', 'value': 'T'},
    {'title': 'U', 'value': 'U'},
    {'title': 'V', 'value': 'V'},
    {'title': 'W', 'value': 'W'},
    {'title': 'W', 'value': 'W'},
    {'title': 'X', 'value': 'X'},
    {'title': 'Y', 'value': 'Y'},
    {'title': 'Z', 'value': 'Z'},
    {'title': '删除', 'value': '删除'},
    {'title': '确认', 'value': '确认'},
  ];
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    chajiaval = widget.oval;
  }
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      height: 210,
      child: Column(
        children: [
          chajiavalwidget(),
          numwidget(),
        charswidget(),
        charswidget2(),
        charswidget3()]
      ),
    );
  }

  Widget chajiavalwidget(){
    return Container(
      height: 50,
      child:
      Center(child:
      Text(chajiaval))
    );
  }

  Widget numwidget() {
    return Row(
      children: List.generate(10,
          (index) => 
          InkWell(
            onTap: (){
              if(chajiaval=="请输入车架号"){
                setState(() {
                  chajiaval = numns[index]['value'];
                });
              }else{
                chajiaval = chajiaval+numns[index]['value'];
              }
            },
            child:
          Container(
            decoration: BoxDecoration(
              border: Border.all(
                color: Colours.text_gray_c,
                width: 0.8
              )
              //color: Colours.text_gray_c
            ),
            height: 40,
            width: MediaQuery.of(context).size.width/10,
            child: Center(child: Text("${numns[index]['title']}"))))),
    );
  }
  Widget charswidget(){
      return Row(
      children: List.generate(10,
          (index) => 
          InkWell(child:
          Container(
            decoration: BoxDecoration(
              border: Border.all(
                color: Colours.text_gray_c,
                width: 0.8
              )
              //color: Colours.text_gray_c
            ),
            height: 40,
            width: MediaQuery.of(context).size.width/10,
            child: Center(child: Text("${numns[index+10]['title']}"))))),
    );
  }
  Widget charswidget2(){
      return Row(
      children: List.generate(10,
          (index) => 
          InkWell(child:
          Container(
            decoration: BoxDecoration(
              border: Border.all(
                color: Colours.text_gray_c,
                width: 0.8
              )
              //color: Colours.text_gray_c
            ),
            height: 40,
            width: MediaQuery.of(context).size.width/10,
            child: Center(child: Text("${numns[index+20]['title']}"))))),
    );
  }
  Widget charswidget3(){
      return Row(
      children: List.generate(9,
          (index) => 
          InkWell(child:
          Container(
            decoration: BoxDecoration(
              border: Border.all(
                color: Colours.text_gray_c,
                width: 0.8
              )
              //color: Colours.text_gray_c
            ),
            height: 40,
            width:index<=6? MediaQuery.of(context).size.width/10:MediaQuery.of(context).size.width/10*1.5,
            child: Center(child: Text("${numns[index+30]['title']}"))))
            ),
    );
  }
}
